﻿CREATE PROCEDURE [dbo].[UpdateMarkCondition]
	@MarkConditionId uniqueidentifier,
    @Mark uniqueidentifier,
    @RequiredMark uniqueidentifier,
	@RequiredActivity uniqueidentifier,
    @IsDeleted bit,
    @LastChanged datetime,
	@LastChangedBy uniqueidentifier,

	@TimeStamp timestamp,
	@newTimeStamp timestamp output

AS

	UPDATE MarkCondition

	SET 

	 Mark = @Mark,
	 RequiredMark = @RequiredMark,
	 RequiredActivity = @RequiredActivity,
	 IsDeleted = @IsDeleted,
	 LastChanged = @LastChanged,
	 LastChangedBy = @LastChangedBy

	WHERE MarkConditionId = @MarkConditionId AND [TimeStamp]=@TimeStamp

  IF @@ROWCOUNT = 0

    RAISERROR('Row has been edited by another user', 16, 1)            	


	SELECT @newTimeStamp = [TimeStamp]

	FROM MarkCondition 

	WHERE MarkConditionId = @MarkConditionId

RETURN 0